package com.itjiange.consumer.listeners;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 接收消息
 *
 * @author ItJiange
 * @date 2023-10-03
 */
@Slf4j
@Component
public class MqListener {
    @RabbitListener(queues = "simple.queue")
    public void listenerSimpleQueue1(String msg) {
        System.out.println("接收到消息为：【" + msg + "】");
    }

    @RabbitListener(queues = "work.queue")
    public void listenerWorkQueue1(String msg) {
        System.out.println("消费者 1 接收到消息为：【" + msg + "】");
    }

    @RabbitListener(queues = "work.queue")
    public void listenerWorkQueue2(String msg) {
        System.err.println("消费者 2 接收到消息为：【" + msg + "】");
    }
}
